//
// Created by 李传智 on 2018/4/12.
//

#ifndef ANDSDK_SHADER_H
#define ANDSDK_SHADER_H

#include <mutex>

enum ShaderType {
    SHADER_YUV420P = 0, // y 4 u 1 v 1 = AV_PIX_FMT_YUV420P
    SHADER_NV12 = 25,   // y 4 uv 1 = AV_PIX_FMT_NV12
    SHADER_NV21 = 26    // y 4 vu 1 = AV_PIX_FMT_NV21
};


class Shader {

public:
    // 初始化
    virtual bool init(int format);

    virtual void close();

    // 获取纹理
    virtual void getTexture(unsigned int index, int width, int height, unsigned char *buf, bool alpha = 0);

    // 绘制
    virtual void draw(int x, int y, int width, int height);

private:
    // 顶点着色器
    unsigned int vertexShader;
    // 片元着色器
    unsigned int fragmentShader;
    // 渲染程序
    unsigned int program;
    // 纹理
    unsigned int textures[3] = {0};

    std::mutex mutex;
};


#endif //ANDSDK_SHADER_H
